package com.wsoft.system.service.impl;

import cn.hutool.core.convert.Convert;
import com.wsoft.core.service.CommonAccountService;
import com.wsoft.core.vo.AccountVO;
import com.wsoft.system.entity.SysAccountEntity;
import com.wsoft.system.query.account.OnlineQuery;
import com.wsoft.system.service.ISysAccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author zhonglj
 * @Date 2024/12/25 18:42
 */
@Service
public class CommonAccountServiceImpl implements CommonAccountService {
    @Resource
    private ISysAccountService accountService;

    @Override
    public List<AccountVO> getAccountList() {
        List<SysAccountEntity> list = accountService.listAll();
        return list.stream().map(e -> Convert.convert(AccountVO.class, e)).collect(Collectors.toList());
    }

    @Override
    public void updateOnline(AccountVO accountVO) {
        OnlineQuery convert = Convert.convert(OnlineQuery.class, accountVO);
        accountService.updateOnline(convert);
    }
}
